﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MvcShop.Models.Repositories
{
    public class RUser:BaseRepository, IUser
    {
        /// <summary>
        /// 已編譯查詢
        /// </summary>
        private static readonly Func<SouthShopEntities1, int, User> CompiledQueryGetUserById = CompiledQuery.Compile<SouthShopEntities1, int, User>((sse, id) => sse.Users.Where(c => c.Id == id).FirstOrDefault());

        #region IRepository<User> 成员

        public User GetById(int id)
        {
            //// 利用 CompiledQuery 取得資料
            return CompiledQueryGetUserById.Invoke(sse, 1);
        }

        public IQueryable<User> GetAll()
        {
            throw new NotImplementedException();
        }

        public void Add(User entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(User entity)
        {
            throw new NotImplementedException();
        }

        public void Update(User entity)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
